<?php

$vSqls[0] = "
DELETE FROM
	cupom_categoria
WHERE
	cd_cupom = '{$_POST['cd_cupom']}'
";

$vSqls[1] = "
DELETE FROM
	cupom_item
WHERE
	cd_cupom = '{$_POST['cd_cupom']}'
";

$vSqls[2] = "
DELETE FROM
	cupom
WHERE
	cd_cupom = '{$_POST['cd_cupom']}'
";

db_trans();

$vErros = 0;

foreach ($vSqls as $vSql) {
	if(!db_query($vSql)) {
		$vErros++;
	}
}

if($vErros === 0) {
	db_commit();
	echo 1;
} else {
	db_rollback();
	echo 0;
}